
global path "YOUR_PATH\Replication_Code"

*** NGDP -----------------------------------------------------------------------
* PC
use "$path\02_OutData\ngdp_data.dta", clear

sum YEAR

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\ngdp_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** RGDP -----------------------------------------------------------------------
* PC
use "$path\02_OutData\rgdp_data.dta", clear

sum YEAR

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\rgdp_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** PGDP -----------------------------------------------------------------------
* PC
use "$path\02_OutData\pgdp_data.dta", clear

sum YEAR

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\pgdp_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** CPI ------------------------------------------------------------------------
* PC
use "$path\02_OutData\cpi_data.dta", clear

sum YEAR

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\cpi_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** INDPROD --------------------------------------------------------------------
* PC
use "$path\02_OutData\indprod_data.dta", clear

sum YEAR

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\indprod_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** RCONSUM --------------------------------------------------------------------
* PC
use "$path\02_OutData\rconsum_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\rconsum_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** RNRESIN --------------------------------------------------------------------
* PC
use "$path\02_OutData\rnresin_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\rnresin_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** RRESINV --------------------------------------------------------------------
* PC
use "$path\02_OutData\rresinv_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\rresinv_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** RFEDGOV --------------------------------------------------------------------
* PC
use "$path\02_OutData\rfedgov_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\rfedgov_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** RSLGOV --------------------------------------------------------------------
* PC
use "$path\02_OutData\rslgov_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\rslgov_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** HOUSING --------------------------------------------------------------------
* PC
use "$path\02_OutData\housing_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\housing_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** Unemployment ---------------------------------------------------------------
* PC
use "$path\02_OutData\unemp_data.dta", clear

sum YEAR

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace


* PIC
use "$path\02_OutData\unemp_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** TBILL ----------------------------------------------------------------------
* PC
use "$path\02_OutData\tbill_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\tbill_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** TBOND ----------------------------------------------------------------------
* PC
use "$path\02_OutData\tbond_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\tbond_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)



*** BOND -----------------------------------------------------------------------
* PC
use "$path\02_OutData\bond_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PC
keep if (median_prior_lag_1 == 2 & rev_3 > 0) | (median_prior_lag_1 == 1 & rev_3 < 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 1

save "$path\02_OutData\betas_pc_ind_macro.dta", replace

* PIC
use "$path\02_OutData\bond_data.dta", clear

egen time_group = group(YEAR QUARTER)
gen constant = 1

* forecaster-by-forecaster
keep if !missing(rev_3)
keep if !missing(fe_3)
* PIC
keep if (median_prior_lag_1 == 2 & rev_3 < 0) | (median_prior_lag_1 == 1 & rev_3 > 0)

bys ID: egen tot_for=count(rev_3)
keep if tot_for>=10
save "$path\more_10.dta", replace

statsby, by(ID): reg fe_3 rev_3
sum _b_rev_3, detail

drop if missing(_b_rev_3)
gen group = 0

append using "$path\02_OutData\betas_pc_ind_macro.dta"
qreg _b_rev_3 group, vce(robust)


